<html>
<head><meta charset="utf-8"><title>rust-fmt from vs code, on save · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rust-fmt.20from.20vs.20code.2C.20on.20save.html">rust-fmt from vs code, on save</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="196778882"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rust-fmt%20from%20vs%20code%2C%20on%20save/near/196778882" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> zeroexcuses <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rust-fmt.20from.20vs.20code.2C.20on.20save.html#196778882">(May 07 2020 at 14:32)</a>:</h4>
<p>Is there a way, to tell vs code, on save, to execute rust-fmt ?</p>



<a name="196787014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rust-fmt%20from%20vs%20code%2C%20on%20save/near/196787014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rust-fmt.20from.20vs.20code.2C.20on.20save.html#196787014">(May 07 2020 at 15:25)</a>:</h4>
<p><code>"editor.formatOnSave": true</code> and make sure <code>rustfmt</code> is installed. You'll also need rust-analyzer (or RLS).</p>



<a name="196787703"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rust-fmt%20from%20vs%20code%2C%20on%20save/near/196787703" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> zeroexcuses <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rust-fmt.20from.20vs.20code.2C.20on.20save.html#196787703">(May 07 2020 at 15:29)</a>:</h4>
<div class="codehilite"><pre><span></span><code>  &quot;editor.formatOnSave&quot;: true
</code></pre></div>


<p>is working because settings.json is getting reformatted on save</p>
<p>rustfmt is installed because it works fine from IntelliJ/Rust on save</p>
<p>however, saving a *.rs file (in the same workspace that worked from IntelliJ) is not triggering a reformat</p>



<a name="196787735"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rust-fmt%20from%20vs%20code%2C%20on%20save/near/196787735" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> zeroexcuses <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rust-fmt.20from.20vs.20code.2C.20on.20save.html#196787735">(May 07 2020 at 15:29)</a>:</h4>
<p>How does vscode know to call |"rustfmt" for *.rs files ?</p>



<a name="196787898"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rust-fmt%20from%20vs%20code%2C%20on%20save/near/196787898" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> zeroexcuses <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rust-fmt.20from.20vs.20code.2C.20on.20save.html#196787898">(May 07 2020 at 15:30)</a>:</h4>
<p>rust-fmt works now on *.rs files</p>



<a name="196805512"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rust-fmt%20from%20vs%20code%2C%20on%20save/near/196805512" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rust-fmt.20from.20vs.20code.2C.20on.20save.html#196805512">(May 07 2020 at 17:40)</a>:</h4>
<p>Code doesn't call rustfmt, it asks the language server to format the file. rust-analyzer sometimes gets a bit stuck and doesn't get to run it like in <a href="https://github.com/rust-analyzer/rust-analyzer/issues/4054" title="https://github.com/rust-analyzer/rust-analyzer/issues/4054">https://github.com/rust-analyzer/rust-analyzer/issues/4054</a>, but it should work.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>